package graphics.tests;

import graphics.Matrix;
import graphics.Vector;
import xml.Xml;
import junit.framework.TestCase;
import logger.Logger;

public class MatrixTest extends TestCase {

	
	public void testGet() {
		Matrix M = Matrix.identity();
		
		assertTrue(M.get(0, 0)==1f);
		assertTrue(M.get(1, 1)==1f);
		assertTrue(M.get(2, 2)==1f);
		assertTrue(M.get(3, 3)==1f);
		
		assertTrue(M.get(0, 1)==0f);
		assertTrue(M.get(0, 2)==0f);
		assertTrue(M.get(0, 3)==0f);
		assertTrue(M.get(1, 0)==0f);
		assertTrue(M.get(1, 2)==0f);
		assertTrue(M.get(1, 3)==0f);
		assertTrue(M.get(2, 0)==0f);
		assertTrue(M.get(2, 1)==0f);
		assertTrue(M.get(2, 3)==0f);
		assertTrue(M.get(3, 0)==0f);
		assertTrue(M.get(3, 1)==0f);
		assertTrue(M.get(3, 2)==0f);
		
	}

	public void testSet() {
		Matrix	M = Matrix.identity();
		int		col, row;
		float	testValue = 9999f;
		
		for(row=0; row<4; row++) {
			for(col=0; col<4; col++) {
				M.set(row,col, testValue);
				assertTrue(M.get(row,col)==testValue);
			}
		}
	}

	public void testGetCol() {
		Matrix	M = Matrix.identity();
		int	col;
		for(col=0; col<4; col++) {
			Vector	V1 = M.getCol(col);
			float	F[] = new float[] {	0f, 0f, 0f, 0f	};
			F[col] = 1f;
			Vector	V2 = new Vector(F);
			assertTrue(V1.equals(V2));
		}
	}

	public void testGetRow() {
		Matrix	M = Matrix.identity();
		int	row;
		for(row=0; row<4; row++) {
			Vector	V1 = M.getRow(row);
			float	F[] = new float[] {	0f, 0f, 0f, 0f	};
			F[row] = 1f;
			Vector	V2 = new Vector(F);
			assertTrue(V1.equals(V2));
		}
	}

	public void testMatrix() {
		Matrix	M = new Matrix( Matrix.Arrays.identity() );
		assertTrue(M!=null);
	}

	public void testMultiply() {
		Matrix	M1 = Matrix.identity();
		Matrix	M2 = new Matrix( new float[][] {
				{	1, 1, 1, 1	},
				{	2, 2, 2, 2	},
				{	3, 3, 3, 3	},
				{	4, 4, 4, 4	}
			}	
		);
		Matrix	M3 = M1.multiply(M2);
		assertTrue(M3.equals(M2));
	}

	public void testTransform() {
		Vector	V1	= new Vector(1f, 1f, 1f);
		Matrix	M	= Matrix.translation(-1, -1, -1);
		Vector	V2	= M.transform(V1);
		
		Logger.println(Xml.write("V1", V1.niceString()));
		Logger.println(Xml.write("V2", V2.niceString()));
		
		assertTrue(V2.equals(new Vector(0f, 0f, 0f)));
	}

	public void testInverse() {
		fail("Not yet implemented");
	}

	public void testClone() {
		fail("Not yet implemented");
	}

	public void testIdentity() {
		fail("Not yet implemented");
	}

	public void testBlank() {
		fail("Not yet implemented");
	}

	public void testScaling() {
		fail("Not yet implemented");
	}

	public void testTranslation() {
		fail("Not yet implemented");
	}

	public void testRotationX() {
		fail("Not yet implemented");
	}

	public void testRotationY() {
		fail("Not yet implemented");
	}

	public void testRotationZ() {
		fail("Not yet implemented");
	}

	public void testRotationXY() {
		fail("Not yet implemented");
	}

	public void testRotationXZ() {
		fail("Not yet implemented");
	}

	public void testRotationYZ() {
		fail("Not yet implemented");
	}

	public void testPerspectiveProjection() {
		fail("Not yet implemented");
	}

	public void testNiceString() {
		fail("Not yet implemented");
	}

}
